/* 
  Copyright (c) SilverLining 2015
  Date:    2016-1-17
  File:    MessageType.h  
  Description: 
	Contains the declaration of the MessageType class.
*/

#pragma once

namespace SL
{
	namespace M
	{
		/// <summary>
		/// Encapsulate the type of a message. This works similarly to how an XName works for Linq to XML.
		/// </summary>
		[Serializable]
		public ref class MessageType sealed : public System::IEquatable<SL::M::MessageType^>, public System::Runtime::Serialization::ISerializable
		{
		public:
			bool Equals(Object^ obj) override;
			int GetHashCode() override;
			String^ ToString() override;

			/// <summary>
			/// Perform equality comparison on the given message.
			/// </summary>
			/// <param name="other">The message type to compare.</param>
			/// <returns>True if the specified message is equal to this one.</returns>
			virtual bool Equals(SL::M::MessageType^ other);

			/// <summary>
			/// Construct a message type from the specified type name, returning it.
			/// </summary>
			/// <param name="typeName">The type name of the message to specify.</param>
			/// <returns>A message type.</returns>
			static MessageType^ Get(String^ typeName);

			/// <summary>
			/// Perform a type conversion.
			/// </summary>
			/// <param name="messageType">The message type to convert, expressed as a string.</param>
			/// <returns>The converted message type.</returns>
			static operator MessageType ^ (String^ messageType);

			/// <summary>
			/// Serialize this object.
			/// </summary>
			/// <param name="info">The serialization info to write to.</param>
			/// <param name="context">The streaming context to use.</param>
			virtual void GetObjectData(System::Runtime::Serialization::SerializationInfo ^ info, System::Runtime::Serialization::StreamingContext context);

		private:
			MessageType(SerializationInfo^ info, StreamingContext context);
			MessageType(String^ typeName);

		internal:
			String^ _type;
		};
	}
}